package com.example;

import com.example.config.event.MyEvent;
import com.example.ms.AppConfig;
import com.example.service.UserService;
import com.example.util.JwtUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.SpringVersion;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author Administrator
 */
@SpringBootApplication

//开启figen远程调用@EnableDiscoveryClient
@EnableFeignClients
//@EnableBinding(ChatProcessor.class)
/**
 * 服务降级或熔断
 */
//@EnableHystrix
public class ElAdminBizApplication {

    public static void main(String[] args) {
        System.out.println("SpringBootVersion：" + SpringBootVersion.getVersion() + ";SpringVersion:" + SpringVersion.getVersion());
        MyEvent event = new MyEvent(new Object());
        event.setMessage("event====================事件发送");

        ConfigurableApplicationContext run = SpringApplication.run(ElAdminBizApplication.class, args);
        // 发布一个事件 ApplicationContext 是一个容器bean 可以再其它地方拿到 用它发布事件即可
        run.publishEvent(event);

    }

    /**
     * 用于加密
     *
     * @return
     */
    @Bean
    public BCryptPasswordEncoder encoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    @ConfigurationProperties("jwt.config")
    public JwtUtil jwtUtil() {
        return new JwtUtil();
    }
}